<html>

 <head><title>CS 564 PHP Project: Managing a Database of Books</title></head>

 <body>

This part simply executes a sql query to obtain all books, then displays
them one by one.<p>

We do not provide a sample implementation for this part, in the book
domain. You will have to implement such a capability for your project
domain.


</body>
   <tr>
     <td colspan="2" align="center" valign="top">
   Here are the search results (searched by title):<br>
       <table border="1" width="75%">
        <tr>
         <td align="center" bgcolor="#cccccc"><b>Name</b></td>
         <td align="center" bgcolor="#cccccc"><b>ID</b></td>
         <td align="center" bgcolor="#cccccc"><b>Type</b></td>
         <td align="center" bgcolor="#cccccc"><b>Rarity</b></td>
        </tr>
 <?php

// Connect to the Database
pg_connect('dbname=cs564_f12 host=postgres.cs.wisc.edu')
or die ("Couldn't Connect ".pg_last_error());
// Get category name and item counts
$query = "SELECT * FROM magic_schema.cards";
// Execute the query and check for errors
$result = pg_query($query);
if (!$result) {
  $errormessage = pg_last_error();
  echo "Error with query: " . $errormessage;
  exit();
}

// get each row and print it out
while($row = pg_fetch_array($result,NULL,PGSQL_ASSOC))  {
  echo "        <tr>";
  echo "\n         <td align=\"center\">";
  echo "\n          ".$row['name'];
  echo "\n         </td>";
  echo "\n         <td align=\"center\">";
  echo "\n          ".$row['card_id'];
  echo "\n         </td>";
  echo "\n         <td align=\"center\">";
  echo "\n          ".$row['type'];
  echo "\n         </td>";
  echo "\n         <td align=\"center\">";
  echo "\n          ".$row['rarity'];
  echo "\n         </td>";
  echo "\n        </tr>";
}
pg_close();
?>
 </table>
     </td>
    </tr>
        <?php echo "<a href=\"https://cs564.cs.wisc.edu/laska/index.ht\
ml\">Back to main page</a>\n"?>
 </body>

</html>
